From df88700230ec00880d1decd9a9b2136a972dcc43 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 11 Jan 2012 00:08:15 +0100 Subject: [PATCH] shorthand: Do an unpack function to assign to everything It's basically the opposite to pack_first_element() - it takes the given value and stores it in all subproperties. --- gtk/gtkcssshorthandpropertyimpl.c | 69 ++++++++----------------------- 1 file changed, 18 insertions(+), 51 deletions(-) diff --git a/gtk/gtkcssshorthandpropertyimpl.c b/gtk/gtkcssshorthandpropertyimpl.c index c3e6332a29..cf06748df4 100644 --- a/gtk/gtkcssshorthandpropertyimpl.c +++ b/gtk/gtkcssshorthandpropertyimpl.c @@ -765,34 +765,28 @@ pack_font_description (GtkCssShorthandProperty *shorthand, } static GParameter * -unpack_border_color (GtkCssShorthandProperty *shorthand, - const GValue *value, - guint *n_params) +unpack_to_everything (GtkCssShorthandProperty *shorthand, + const GValue *value, + guint *n_params) { - GParameter *parameter = g_new0 (GParameter, 4); - gpointer p; + GtkCssStyleProperty *prop; + GParameter *parameter; + guint i, n; GType type; + n = _gtk_css_shorthand_property_get_n_subproperties (shorthand); + parameter = g_new0 (GParameter, n); type = G_VALUE_TYPE (value); - parameter[0].name = "border-top-color"; - g_value_init (¶meter[0].value, type); - parameter[1].name = "border-right-color"; - g_value_init (¶meter[1].value, type); - parameter[2].name = "border-bottom-color"; - g_value_init (¶meter[2].value, type); - parameter[3].name = "border-left-color"; - g_value_init (¶meter[3].value, type); - - /* can be RGBA or symbolic color */ - p = g_value_get_boxed (value); - - g_value_set_boxed (¶meter[0].value, p); - g_value_set_boxed (¶meter[1].value, p); - g_value_set_boxed (¶meter[2].value, p); - g_value_set_boxed (¶meter[3].value, p); + for (i = 0; i < n; i++) + { + prop = _gtk_css_shorthand_property_get_subproperty (shorthand, i); + parameter[i].name = _gtk_style_property_get_name (GTK_STYLE_PROPERTY (prop)); + g_value_init (¶meter[i].value, type); + g_value_copy (value, ¶meter[i].value); + } - *n_params = 4; + *n_params = n; return parameter; } @@ -823,33 +817,6 @@ pack_first_element (GtkCssShorthandProperty *shorthand, } } -static GParameter * -unpack_border_style (GtkCssShorthandProperty *shorthand, - const GValue *value, - guint *n_params) -{ - GParameter *parameter = g_new0 (GParameter, 4); - GtkBorderStyle style; - - style = g_value_get_enum (value); - - parameter[0].name = "border-top-style"; - g_value_init (¶meter[0].value, GTK_TYPE_BORDER_STYLE); - g_value_set_enum (¶meter[0].value, style); - parameter[1].name = "border-right-style"; - g_value_init (¶meter[1].value, GTK_TYPE_BORDER_STYLE); - g_value_set_enum (¶meter[1].value, style); - parameter[2].name = "border-bottom-style"; - g_value_init (¶meter[2].value, GTK_TYPE_BORDER_STYLE); - g_value_set_enum (¶meter[2].value, style); - parameter[3].name = "border-left-style"; - g_value_init (¶meter[3].value, GTK_TYPE_BORDER_STYLE); - g_value_set_enum (¶meter[3].value, style); - - *n_params = 4; - return parameter; -} - static void _gtk_css_shorthand_property_register (const char *name, GType value_type, @@ -930,13 +897,13 @@ _gtk_css_shorthand_property_init_properties (void) GDK_TYPE_RGBA, border_color_subproperties, parse_border_color, - unpack_border_color, + unpack_to_everything, pack_first_element); _gtk_css_shorthand_property_register ("border-style", GTK_TYPE_BORDER_STYLE, border_style_subproperties, parse_border_style, - unpack_border_style, + unpack_to_everything, pack_first_element); _gtk_css_shorthand_property_register ("border-image", G_TYPE_NONE, -- 2.30.2